//https://leetcode.cn/problems/find-minimum-in-rotated-sorted-array/description/
//方法1：
class Solution {
    public int findMin(int[] nums) {
        int left = 0;
        int right = nums.length-1;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] <= nums[nums.length-1]) {
                right = mid;
            }else {
                left = mid + 1;
            }
        }
        return nums[left];
    }
}
//方法2：（需考虑边界情况-》数组全部翻转）
class Solution2 {
    public int findMin(int[] nums) {
        int left = 0;
        int right = nums.length-1;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] < nums[0]) {
                right = mid;
            }else {
                left = mid + 1;
            }
        }
        if (nums[left] > nums[0]) {
            return nums[0];
        }
        return nums[left];
    }
}